package com.mask.im.business.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description:
 * @author: jian
 * @date: 2025/11/17
 */
@Configuration
public class RedissionConfig {
    @Bean
    public RedissonClient redissonClient(@Value("${spring.redis.host}") String host,
                                         @Value("${spring.redis.port}") String port) {
        Config config = new Config();
        // 单节点模式
        config.useSingleServer()
                .setAddress("redis://" + host + ":" + port)
                .setConnectionPoolSize(64)
                .setConnectionMinimumIdleSize(10);
        // 集群模式示例
        // config.useClusterServers().addNodeAddress("redis://node1:6379", "redis://node2:6380");
        return Redisson.create(config);
    }
}
